import { FC, ReactNode } from "react";
import { Navigate } from "react-router-dom";

// 获取token
const getToken = () => {
  return localStorage.getItem("token");
};

// export const AuthRouter: any = () => {
//   const token = getToken();

//   if (!token) {
//     return <Navigate to="/login" />;
//   } else {
//     return <Navigate to="/admin" />;
//   }
// };

export const AuthRouter = ({ children }: any) => {
  const token = getToken();

  if (!token) {
    return <Navigate to="/login" />;
  } else {
    return <>{children}</>;
  }
};
